package javaDesignModel.singletonPattern;

/**
 * Created by Administrator on 2017/3/15 0015.
 * Initialization on Demand Holder IoDH技术
 */
public class Singleton {
    private static class HoldClass {
        private final static Singleton instance = new Singleton();

        static {
            System.out.print("测试内部类执行几次");
        }
    }

    public static Singleton getIntance() {
        System.out.print("测试初始化是否执行");
        return HoldClass.instance;
    }

    public static void main(String[] args) {
        Singleton s1, s2;
        s1 = Singleton.getIntance();
        s2 = Singleton.getIntance();
        System.out.print(s1 == s2);
    }
}
